package main

import (
    "facecat"
    "io/ioutil"
)

/*
* 重绘背景的实现方法
* view:视图
* paint:绘图对象
* clipRect:裁剪区域
*/
func OnPaint(view *facecat.FCView, paint *facecat.FCPaint, clipRect facecat.FCRect) {
    facecat.OnPaintDefault(view, paint, clipRect)
    if view.ViewName == "TabPage"{
		paint.DrawLine("rgb(255,0,0)", 1, 0, 100, 100, 300, 300)
		paint.DrawLine("rgb(255,0,255)", 1, 2, 100, 300, 300, 100)
    }else if view.ViewName == "TabPage2"{
		paint.DrawRect("rgb(0,255,0)", 1, 0, 100, 100, 200, 200)
		paint.FillRect("rgb(0,255,255)", 250, 250, 350, 350)
	}else if view.ViewName == "TabPage3"{
		paint.DrawEllipse("rgb(0,255,255)", 1, 0, 100, 100, 200, 200)
		paint.FillEllipse("rgb(255,0,255)", 250, 250, 350, 350)
	}else if view.ViewName == "TabPage4"{
		paint.DrawText("FaceCat", "rgb(255,0,0)", "Default,30", 100, 100)
	}else if view.ViewName == "TabPage5"{
		var drawPoints []facecat.FCPoint
		drawPoints = append(drawPoints, facecat.CreatePoint(100, 100))
		drawPoints = append(drawPoints, facecat.CreatePoint(150, 120))
		drawPoints = append(drawPoints, facecat.CreatePoint(130, 200))
		drawPoints = append(drawPoints, facecat.CreatePoint(200, 200))
		drawPoints = append(drawPoints, facecat.CreatePoint(250, 220))
		paint.DrawPolyline("rgb(255,0,0)", 1, 0, drawPoints)
	}else if view.ViewName == "TabPage6"{
		var drawPoints []facecat.FCPoint
		drawPoints = append(drawPoints, facecat.CreatePoint(100, 100))
		drawPoints = append(drawPoints, facecat.CreatePoint(150, 120))
		drawPoints = append(drawPoints, facecat.CreatePoint(200, 200))
		drawPoints = append(drawPoints, facecat.CreatePoint(150, 200))
		paint.FillPolygon("rgb(0,0,255)", drawPoints)
    }
}

var gPaint = facecat.CreatePaint()

func WndProc(hwnd facecat.HWND, msg uint32, wParam, lParam uintptr) (result uintptr) {
    return facecat.WndProcDefault(gPaint, hwnd, msg, wParam, lParam)
}

func main() {
    gPaint.OnPaint = OnPaint
    facecat.CreateMainWindow(gPaint, "FaceCat-Go", WndProc)
    xmlStr, _ := ioutil.ReadFile("xml//paintexample.xml")
    facecat.RenderFaceCat(gPaint, string(xmlStr))
    facecat.ShowWindow(gPaint)
}